import requests
# import re
# from bs4 import BeautifulSoup
from selenium import webdriver
import time

header={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"}
# response = requests.get("https://www.baidu.com",headers=header)
# response = requests.get("https://finance.sina.com.cn/realstock/company/sh000001/nc.shtml",headers=header)
# print(response.text)
# print(response.encoding)

# result = re.findall('<p>(.*?)</p>',response.text)
# print(result)

# soup = BeautifulSoup(response.text,"html.parser")
# print(soup.prettify())
# print(soup.select('p')[0].get_text())

# browser = webdriver.Chrome()
# browser.maximize_window()
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
# browser = webdriver.Chrome(options=chrome_options)
browser = webdriver.Chrome()
browser.get("https://www.baidu.com")

browser.find_element(by="xpath",value="//*[@id='kw']").send_keys("python")
browser.find_element(by="xpath",value="//*[@id='su']").click()
time.sleep(10)
data = browser.page_source
print(data)
browser.quit()